//
//  GetAward.m
//  PokerPlus
//
//  Created by Lv Changye on 11-7-29.
//  Copyright 2011年 139me. All rights reserved.
//

#import "GetAward.h"


@implementation GetAward

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [validateCode release];
    [textField release];
    [lingQu release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    validateCode.text=@"WdEht";
    
    
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
-(void)viewWillAppear:(BOOL)animated{
    
    NSLog(@"Will Appear!");
    [super viewWillAppear:animated];
}
- (void)viewDidUnload
{
    [validateCode release];
    validateCode = nil;
    [textField release];
    textField = nil;
    [lingQu release];
    lingQu = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)getAward:(id)sender {
    [textField resignFirstResponder];
    
    if ([[textField.text lowercaseString]isEqualToString:[validateCode.text lowercaseString]]) {
        textField.enabled=NO;
        lingQu.enabled=NO;
        UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 522, 271)];
        imageview.image=[UIImage imageNamed:@"获得了.png"];
        UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(250, 130, 200, 100)];
        //label.font=[UIFont fontWithName:@"Courier New" size:50];
        label.font=[UIFont boldSystemFontOfSize:50];
        label.text=@"$8000";
        label.backgroundColor=[UIColor clearColor];
        label.textColor=[UIColor colorWithRed:1.0 green:0.75 blue:0.16 alpha:1.0];
        label.textAlignment=UITextAlignmentCenter;
        
        [self.view addSubview:imageview];
        [imageview addSubview:label];
        imageview.alpha=0.0;
        
        [UIImageView beginAnimations:@"image" context:nil];
        [UIImageView setAnimationDuration:0.4];
        imageview.alpha=1.0;
        [UIImageView commitAnimations];
        [label release];
        [imageview release];
        
    }
    else{
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"验证码输入有误" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    NSLog(@"%@",textField.text);
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    NSLog(@"END Editing!");
}
@end
